- var language = current.path[1]
- var title = "JavaScript "
- var filter = /(\.html$)/
- var replace = /(\.html$)|(^index\.html$)/
- var version = ''
- var page = ''

//- Replace _ underscores with . dots
if current.path[2]
  - var version = current.path[2].replace(/\_+/gm, ".")

if current.path[6]
  if public.docs[current.path[1]][current.path[2]][current.path[3]][current.path[4]][current.path[5]][current.path[6]]
    - var page = current.path[3] + '/' + current.path[4] + '/' + current.path[5] + '/' + current.path[6] + '/'
  else
    - var page = current.path[3] + '/' + current.path[4] + '/' + current.path[5] + '/' + current.path[6] + '.html'

else if current.path[5]
  if public.docs[current.path[1]][current.path[2]][current.path[3]][current.path[4]][current.path[5]]
    - var page = current.path[3] + '/' + current.path[4] + '/' + current.path[5] + '/'
  else
    - var page = current.path[3] + '/' + current.path[4] + '/' + current.path[5] + '.html'

else if current.path[4]
  if public.docs[current.path[1]][current.path[2]][current.path[3]][current.path[4]]
    - var page = current.path[3] + '/' + current.path[4] + '/'
  else
    - var page = current.path[3] + '/' + current.path[4] + '.html'

else if current.path[3]
  if public.docs[current.path[1]][current.path[2]][current.path[3]]
    - var page = current.path[3] + '/'
  else
    - var page = current.path[3] + '.html'

//- VERSION TREE CREATOR MIXIN
mixin tree(directory, urlPrefix, name, latest)
  for val, semvar in directory
    if semvar !== '.git' && semvar !== '_data'
      - var libVersion = (semvar == "latest") ?  latest : semvar.replace(/\_+/gm, ".")
      li <a href="#{urlPrefix}/#{semvar}/#{page}" md-button>#{name} #{libVersion}</a>


//- BUTTON TITLE GENERATION
if language == 'ts'
  if version == "latest"
    - var title = 'Angular for TypeScript'
  else
    - var title = 'Angular ' + version + ' for TypeScript'

if language == 'js'
  if version == "latest"
    - var title = 'Angular for JavaScript'
  else
    - var title = 'Angular ' + version + ' for JavaScript'


if language == 'dart'
  if version == "latest"
    - var title = 'Angular for Dart'
  else
    - var title = 'Angular ' + version + ' for Dart'

if current.path[4] !== 'change-log'
  //- DROPDOWN BUTTON
  nav.dropdown
    button(aria-label="选择Angular版本" md-button class="dropdown-button" ng-click="appCtrl.toggleVersionMenu($event)") #{title}  <span class="icon icon-arrow-drop-down"></span>
    div(class="overlay ng-hide" ng-click="appCtrl.toggleVersionMenu($event)" ng-show="appCtrl.showMenu")

    //- DROPDOWN MENU
    ul(class="dropdown-menu" ng-class="appCtrl.showMenu ? 'is-visible' : ''")
      mixin tree(public.docs.ts, "/docs/ts", "Angular for TypeScript")
      mixin tree(public.docs.js, "/docs/js", "Angular for JavaScript")
      //- Disable cross-language link for API entry pages (but keep for top API search page):
      - var isApiEntryPage = current.path[3] === 'api' && public.docs[current.path[1]][current.path[2]][current.path[3]][current.path[4]]
      if public.docs.dart && !isApiEntryPage
        mixin tree(public.docs.dart, "/docs/dart", "Angular for Dart")
